package com.francis.spring.framework.aop.aspect;

import com.francis.spring.framework.aop.intercept.FrancisMethodInterceptor;
import com.francis.spring.framework.aop.intercept.FrancisMethodInvocation;

import java.lang.reflect.Method;

/**
 * @Author Francis
 * @Date 2020/11/22 22:33
 * @Version 1.0
 * @Description:
 */
public class FrancisAfterThrowingAdviceInterceptor extends FrancisAbstractAspectAdvice implements FrancisAdvice, FrancisMethodInterceptor {


    private String throwingName;

    public FrancisAfterThrowingAdviceInterceptor(Method aspectMethod, Object aspectTarget) {
        super(aspectMethod, aspectTarget);
    }

    @Override
    public Object invoke(FrancisMethodInvocation mi) throws Throwable {
        try {
            return mi.proceed();
        }catch (Throwable e){
            invokeAdviceMethod(mi,null,e.getCause());
            throw e;
        }
    }

    public void setThrowName(String throwName){
        this.throwingName = throwName;
    }
}
